package cn.hp.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
@RequestMapping("/page")
public class PageController {

    @RequestMapping("/to_index")
    public String index() {
        return "/html/customerPhone/index.html";
    }

    @RequestMapping("/to_login")
    public String to_login() {
        return "/html/customerPhone/html/login.html";
    }


    @RequestMapping("/to_phoneList")
    public String to_phoneList() {
        return "/html/customerPhone/html/order.html";
    }

    /**
     * 跳转 管理员登录页面
     */
    @RequestMapping("/to_serviceLogin")
    public String to_serviceLogin() {
        return "/html/customerService/login.html";
    }

    /**
     * 获取登录图片验证码
     *
     */
    @RequestMapping("/generateCheckCode")
    public void generateCheckCode(HttpSession session, HttpServletResponse response) throws IOException {
        CircleCaptcha circleCaptcha = CaptchaUtil.createCircleCaptcha(110, 40, 1, 6);
        String code = circleCaptcha.getCode();
        System.out.println(code);
        session.setAttribute("code",code);
        circleCaptcha.write(response.getOutputStream());
    }

    /**
     * 跳转 管理员 页面
     */
    @RequestMapping("/service_index")
    public String service_index(){
        return "/html/customerService/back.html";
    }


    @RequestMapping("/selectList")
    public String selectList(){
        return "/html/orders/table.html";
    }

    @RequestMapping("/to_addOrder")
    public String to_addOrder(){
        return "/html/orders/addOrder.html";
    }

    /**
     * 管理员跳转到修改状态界面
     */
    @RequestMapping("/updStatus")
    public String updStatus(){
        return "/html/orders/updStatus.html";
    }

    /***
     * 跳转到技师管理页面
     * @return
     */
    @RequestMapping("/to_masterSelectList")
    public String to_masterSelectList(){
        return "/html/master/table.html";
    }

    @RequestMapping("/to_sendMaster")
    public String to_sendMaster(){
        return "/html/orders/master/table.html";
    }
}